package 适配器模式.对象适配器模式;

import java.util.ArrayList;
import java.util.List;

public class AdapterTest1 {
    public static void main(String[] args) {
        Adaptee adaptee = new Adaptee();
        Target target = new Adapter(adaptee);
        target.output5v();
        List list = new ArrayList();
    }
}

/**
 * 电源
 */
class Adaptee {
    public  int output220v(){
        return 220;
    }
}

/**
 * 电器接口
 */
interface Target{
    int output5v();
}

/**
 * 对象适配器模式
 */
class Adapter implements Target{
    private Adaptee adaptee;

    public Adapter(Adaptee adaptee) {
        this.adaptee = adaptee;
    }

    @Override
    public int output5v() {
        int i = adaptee.output220v();
        System.out.println("原始电压"+i+"v 转为 5v");
        return 5;
    }
}